Skip to content

Fix OIDC token refresh failing on Windows in the asyncio client - #2668

Merged
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
ealeonraz:fix-oidc-refresh-tempfile-windows-async
Aug 5, 2026
Merged

Fix OIDC token refresh failing on Windows in the asyncio client#2668
kubernetes-prow[bot] merged 1 commit into
kubernetes-client:masterfrom
ealeonraz:fix-oidc-refresh-tempfile-windows-async

Conversation

@ealeonraz

Copy link
Copy Markdown
Contributor

The asyncio client has the same Windows failure as #2644, in a different
form. _refresh_oidc writes through the open NamedTemporaryFile handle,
so it avoids the traceback in that PR, but it then passes certfile.name
to OpenIDRequestor while the handle is still open. On Windows a second
open of that path fails, so any consumer reading the CA cert by path hits
a PermissionError.

This applies the same fix. The aio module had no module-level
_create_temp_file_with_content, only a FileOrData method, so this adds
the module-level helper mirroring kubernetes/base/config/kube_config.py
and points the existing method at it, which also closes a descriptor that
mkstemp leaked.

Note the CA cert temp file now lives until process exit and is cleaned by
the existing _cleanup_temp_files atexit hook, matching the sync client,
rather than being removed when the with block ended.

Verified on Windows 11 / Python 3.14:

new helper:   reopened by path OK, 59 bytes
old pattern:  PermissionError [Errno 13] Permission denied

kubernetes/aio/config/kube_config_test.py: 61 passed.

Follow-up to #2644, requested by @yliaog.

Fix OIDC token refresh failing on Windows in the asyncio client when idp-certificate-authority-data is set

_refresh_oidc passed the name of an open NamedTemporaryFile to
OpenIDRequestor. On Windows the file cannot be reopened by path while the
original handle is alive, so any consumer reading the CA cert fails.

Add the module-level _create_temp_file_with_content helper, mirroring
kubernetes/base/config/kube_config.py, and use it for the CA cert. The
FileOrData method now delegates to it, which also closes the descriptor
that mkstemp returned.

Follow-up to kubernetes-client#2644.
@kubernetes-prow kubernetes-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 5, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from roycaihw and yliaog August 5, 2026 09:54
@ealeonraz

Copy link
Copy Markdown
Contributor Author

/kind bug

@ealeonraz

Copy link
Copy Markdown
Contributor Author

/assign @yliaog

@kubernetes-prow kubernetes-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 5, 2026
@kubernetes-prow kubernetes-prow Bot removed the needs-kind Indicates a PR lacks a `kind/foo` label and requires one. label Aug 5, 2026
@yliaog

yliaog commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

thanks for the PR

/lgtm
/approve

@kubernetes-prow kubernetes-prow Bot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 5, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ealeonraz, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 5, 2026
@kubernetes-prow
kubernetes-prow Bot merged commit bc2949f into kubernetes-client:master Aug 5, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants